home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Mixed Mode Maddness / Emulator / Unused / OpCode.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  15.1 KB  |  889 lines

  1. #include "6502.h"
  2. #include "global.h"
  3. #include "stack.h"
  4. #include "bcd.h"
  5.  
  6. #define SETSTATUSBIT(bit)    regP |= bit
  7. #define CLEARSTATUSBIT(bit)    regP &= ~bit
  8. #define GETSTATUS(bit)        ((regP & bit) ? 1 : 0)
  9.  
  10. #define SETNSTATUS(reg) if (reg & NBit)    SETSTATUSBIT(NBit); else CLEARSTATUSBIT(NBit)
  11. #define SETZSTATUS(reg)    if (reg == 0)     SETSTATUSBIT(ZBit); else CLEARSTATUSBIT(ZBit)
  12.  
  13. #define UInt8ToSInt16(num)        ((num & 0x7F) * ((num & 0x80) ? -1 : 1))
  14.  
  15. #define NMI 0xFFFA                // NON MASKABLE INTERUPT VECTOR
  16. #define RES 0xFFFC                // RESET VECTOR
  17. #define IRQ    0xFFFE                // INTERUPT REQUEST VECTOR
  18.  
  19. //////////////////////////////////////////////
  20. //
  21. //    ADC        Add with Carry to A
  22. //
  23. //////////////////////////////////////////////
  24. void _ADC(UInt8 opByte)
  25. {
  26.     SInt16 l_a, h_a, l_opByte, h_opByte, l_result, h_result, result, tempA, tempopByte;
  27.  
  28.     if (GETSTATUS(DBit)) {
  29.         l_a = (regA & 0x0F);
  30.         h_a = ((regA & 0xF0) >> 4);
  31.         l_opByte = (opByte & 0x0F);
  32.         h_opByte = ((opByte & 0xF0) >> 4);
  33.  
  34.         l_result = (l_a + l_opByte + GETSTATUS(CBit));
  35.         h_result = (l_result > 9) ? (h_a + h_opByte + 1) : (h_a + h_opByte);
  36.  
  37.         if (h_result > 9) {
  38.             SETSTATUSBIT(CBit);
  39.         }
  40.         else {
  41.             CLEARSTATUSBIT(CBit);
  42.         }
  43.         regA = (((h_result % 10) << 4) + (l_result % 10));
  44.     }
  45.     else {
  46.         result = (regA + opByte + GETSTATUS(CBit));
  47.  
  48.         tempA = UInt8ToSInt16(regA);
  49.         tempopByte = UInt8ToSInt16(opByte);
  50.  
  51.         if (((tempA<128) && (tempopByte<128) && ((result%256)>127)) ||
  52.             ((tempA>127) && (tempopByte>127) && ((result%256<128)))) {
  53.             SETSTATUSBIT(VBit);
  54.         }
  55.         else {
  56.             CLEARSTATUSBIT(VBit);
  57.         }
  58.  
  59.         regA = (result % 256);
  60.         if (result > 255) {
  61.             SETSTATUSBIT(CBit);
  62.         }
  63.         else {
  64.             CLEARSTATUSBIT(CBit);
  65.         }
  66.     }
  67.     SETNSTATUS(regA);
  68.     SETZSTATUS(regA);
  69. }
  70.  
  71. //////////////////////////////////////////////
  72. //
  73. //    AND        And to A
  74. //
  75. //////////////////////////////////////////////
  76. void _AND(UInt8 opByte)
  77. {
  78.     regA &= opByte;
  79.     if (GETSTATUS(CBit)) {
  80.         ++regA;
  81.     }
  82.     SETNSTATUS(regA);
  83.     SETZSTATUS(regA);
  84. }
  85.  
  86. //////////////////////////////////////////////
  87. //
  88. //    _ASL        Arithmetic shift left
  89. //
  90. //////////////////////////////////////////////
  91. void _ASL(UInt8* addr)
  92. {
  93.     UInt8 theBye = ((*addr) << 1);
  94.     if (*addr & 0x80)
  95.         SETSTATUSBIT(CBit);
  96.     else
  97.         CLEARSTATUSBIT(CBit);
  98.  
  99.     *addr = theBye;
  100.     SETNSTATUS(theBye);
  101.     SETZSTATUS(theBye);
  102. }
  103.  
  104. //////////////////////////////////////////////
  105. //
  106. //    _BCC        Branch Carry Clear
  107. //
  108. //////////////////////////////////////////////
  109. void _BCC(UInt8 opByte)
  110. {
  111.     SInt8 theOffset = 0;
  112.     if (GETSTATUS(CBit) == 0) {
  113.         theOffset |= opByte;
  114.         if (theOffset < 0) {
  115.             pc -= (-theOffset);
  116.         }
  117.         else {
  118.             pc += theOffset;
  119.         }
  120.     }
  121. }
  122.  
  123. //////////////////////////////////////////////
  124. //
  125. //    _BCS        Branch Carry Set
  126. //
  127. //////////////////////////////////////////////
  128. void _BCS(UInt8 opByte)
  129. {
  130.     SInt8 theOffset = 0;
  131.     if (GETSTATUS(CBit)) {
  132.         theOffset |= opByte;
  133.         if (theOffset < 0) {
  134.             pc -= (-theOffset);
  135.         }
  136.         else {
  137.             pc += theOffset;
  138.         }
  139.     }
  140. }
  141.  
  142. //////////////////////////////////////////////
  143. //
  144. //    _BEQ        Branch Equal
  145. //
  146. //////////////////////////////////////////////
  147. void _BEQ(UInt8 opByte)
  148. {
  149.     SInt8 theOffset = 0;
  150.     if (GETSTATUS(ZBit)) {
  151.         theOffset |= opByte;
  152.         if (theOffset < 0) {
  153.             pc -= (-theOffset);
  154.         }
  155.         else {
  156.             pc += theOffset;
  157.         }
  158.     }
  159. }
  160.  
  161. //////////////////////////////////////////////
  162. //
  163. //    _BNE        Branch Not Equal
  164. //
  165. //////////////////////////////////////////////
  166. void _BNE(UInt8 opByte)
  167. {
  168.     SInt8 theOffset = 0;
  169.     if (GETSTATUS(ZBit) == 0) {
  170.         theOffset |= opByte;
  171.         if (theOffset < 0) {
  172.             pc -= (-theOffset);
  173.         }
  174.         else {
  175.             pc += theOffset;
  176.         }
  177.     }
  178. }
  179.  
  180. //////////////////////////////////////////////
  181. //
  182. //    _BMI        Branch Minus
  183. //
  184. //////////////////////////////////////////////
  185. void _BMI(UInt8 opByte)
  186. {
  187.     SInt8 theOffset = 0;
  188.     if (GETSTATUS(NBit)) {
  189.         theOffset |= opByte;
  190.         if (theOffset < 0) {
  191.             pc -= (-theOffset);
  192.         }
  193.         else {
  194.             pc += theOffset;
  195.         }
  196.     }
  197. }
  198.  
  199. //////////////////////////////////////////////
  200. //
  201. //    _BPL        Branch Plus
  202. //
  203. //////////////////////////////////////////////
  204. void _BPL(UInt8 opByte)
  205. {
  206.     SInt8 theOffset = 0;
  207.     if (GETSTATUS(NBit) == 0) {
  208.         theOffset |= opByte;
  209.         if (theOffset < 0) {
  210.             pc -= (-theOffset);
  211.         }
  212.         else {
  213.             pc += theOffset;
  214.         }
  215.     }
  216. }
  217.  
  218. //////////////////////////////////////////////
  219. //
  220. //    _BVC        Branch Overflow Clear
  221. //
  222. //////////////////////////////////////////////
  223. void _BVC(UInt8 opByte)
  224. {
  225.     SInt8 theOffset = 0;
  226.     if (GETSTATUS(VBit) == 0) {
  227.         theOffset |= opByte;
  228.         if (theOffset < 0) {
  229.             pc -= (-theOffset);
  230.         }
  231.         else {
  232.             pc += theOffset;
  233.         }
  234.     }
  235. }
  236.  
  237. //////////////////////////////////////////////
  238. //
  239. //    _BVS        Branch Overflow Set
  240. //
  241. //////////////////////////////////////////////
  242. void _BVS(UInt8 opByte)
  243. {
  244.     SInt8 theOffset = 0;
  245.     if (GETSTATUS(VBit)) {
  246.         theOffset |= opByte;
  247.         if (theOffset < 0) {
  248.             pc -= (-theOffset);
  249.         }
  250.         else {
  251.             pc += theOffset;
  252.         }
  253.     }
  254. }
  255.  
  256. //////////////////////////////////////////////
  257. //
  258. //    _BIT    And With Accumulator (A Unchanged)
  259. //
  260. //////////////////////////////////////////////
  261. void _BIT(UInt8* addr)
  262. {
  263.     UInt8 theBye = *addr;
  264.  
  265.     theBye &= regA;
  266.     SETNSTATUS(theBye);
  267.     SETZSTATUS(theBye);
  268.     if (theBye & 0x40)
  269.         SETSTATUSBIT(VBit);
  270.     else
  271.         CLEARSTATUSBIT(VBit);
  272. }
  273.  
  274. //////////////////////////////////////////////
  275. //
  276. //    _BRK        Break
  277. //
  278. //////////////////////////////////////////////
  279. void _BRK(void)
  280. {
  281.     regP |= BBit;
  282.     PushWord(pc);
  283.     PushByte(regP);
  284.     pc = IRQ;
  285.     return;
  286. }
  287.  
  288. //////////////////////////////////////////////
  289. //
  290. //    _CLC        Clear carry
  291. //
  292. //////////////////////////////////////////////
  293. void _CLC(void)
  294. {
  295.     regP &= ~CBit;
  296. }
  297.  
  298. //////////////////////////////////////////////
  299. //
  300. //    _CLD        Clear Decimal
  301. //
  302. //////////////////////////////////////////////
  303. void _CLD(void)
  304. {
  305.     regP &= ~DBit;
  306. }
  307.  
  308. //////////////////////////////////////////////
  309. //
  310. //    _CLI        Clear Interupt
  311. //
  312. //////////////////////////////////////////////
  313. void _CLI(void)
  314. {
  315.     regP &= ~IBit;
  316. }
  317.  
  318. //////////////////////////////////////////////
  319. //
  320. //    _CLV        Clear Overflow
  321. //
  322. //////////////////////////////////////////////
  323. void _CLV(void)
  324. {
  325.     regP &= ~VBit;
  326. }
  327.  
  328. //////////////////////////////////////////////
  329. //
  330. //    _CMP        Compare to A
  331. //
  332. //////////////////////////////////////////////
  333. void _CMP(UInt8 opByte)
  334. {
  335.     SInt16 tempregA, tempopByte, result;
  336.  
  337.     tempregA = UInt8ToSInt16(regA);
  338.     tempopByte = UInt8ToSInt16(opByte);
  339.     
  340.     result = tempregA - tempopByte;
  341.     if (result < 0) {
  342.         result += 256;
  343.         CLEARSTATUSBIT(CBit);
  344.     }
  345.     else {
  346.         SETSTATUSBIT(CBit);
  347.     }
  348.     SETNSTATUS(result);
  349.     SETZSTATUS(result);
  350. }
  351.  
  352. //////////////////////////////////////////////
  353. //
  354. //    _CPX        Compare to X
  355. //
  356. //////////////////////////////////////////////
  357. void _CPX(UInt8 opByte)
  358. {
  359.     SInt16 tempregX, tempopByte, result;
  360.  
  361.     tempregX = UInt8ToSInt16(regX);
  362.     tempopByte = UInt8ToSInt16(opByte);
  363.     
  364.     result = tempregX - tempopByte;
  365.     if (result < 0) {
  366.         result += 256;
  367.         CLEARSTATUSBIT(CBit);
  368.     }
  369.     else {
  370.         SETSTATUSBIT(CBit);
  371.     }
  372.     SETNSTATUS(result);
  373.     SETZSTATUS(result);
  374. }
  375.  
  376. //////////////////////////////////////////////
  377. //
  378. //    _CPY        Compare to Y
  379. //
  380. //////////////////////////////////////////////
  381. void _CPY(UInt8 opByte)
  382. {
  383.     SInt16 tempregY, tempopByte, result;
  384.  
  385.     tempregY = UInt8ToSInt16(regY);
  386.     tempopByte = UInt8ToSInt16(opByte);
  387.     
  388.     result = tempregY - tempopByte;
  389.     if (result < 0) {
  390.         result += 256;
  391.         CLEARSTATUSBIT(CBit);
  392.     }
  393.     else {
  394.         SETSTATUSBIT(CBit);
  395.     }
  396.     SETNSTATUS(result);
  397.     SETZSTATUS(result);
  398. }
  399.  
  400. //////////////////////////////////////////////
  401. //
  402. //    _DEC    Decrement by one
  403. //
  404. //////////////////////////////////////////////
  405. void _DEC(UInt8* addr)
  406. {
  407.     UInt8 theBye = *addr;
  408.  
  409.     theBye--;
  410.     SETNSTATUS(theBye);
  411.     SETZSTATUS(theBye);
  412.      *addr = theBye;
  413. }
  414.  
  415. //////////////////////////////////////////////
  416. //
  417. //    _DEX    Decrement X by one
  418. //
  419. //////////////////////////////////////////////
  420. void _DEX(void)
  421. {
  422.     regX--;
  423.     SETNSTATUS(regX);
  424.     SETZSTATUS(regX);
  425. }
  426.  
  427. //////////////////////////////////////////////
  428. //
  429. //    _DEY    Decrement Y by one
  430. //
  431. //////////////////////////////////////////////
  432. void _DEY(void)
  433. {
  434.     regY--;
  435.     SETNSTATUS(regY);
  436.     SETZSTATUS(regY);
  437. }
  438.  
  439. //////////////////////////////////////////////
  440. //
  441. //    _EOR        XOR to Y
  442. //
  443. //////////////////////////////////////////////
  444. void _EOR(UInt8 opByte)
  445. {
  446.     regA ^= opByte;
  447.  
  448.     SETNSTATUS(regA);
  449.     SETZSTATUS(regA);
  450. }
  451.  
  452. //////////////////////////////////////////////
  453. //
  454. //    _INC    Increment by one
  455. //
  456. //////////////////////////////////////////////
  457. void _INC(UInt8* addr)
  458. {
  459.     UInt8 theBye = *addr;
  460.  
  461.     theBye++;
  462.     SETNSTATUS(theBye);
  463.     SETZSTATUS(theBye);
  464.      *addr = theBye;
  465. }
  466.  
  467. //////////////////////////////////////////////
  468. //
  469. //    _INX    Increment X by one
  470. //
  471. //////////////////////////////////////////////
  472. void _INX(void)
  473. {
  474.     regX++;
  475.     SETNSTATUS(regX);
  476.     SETZSTATUS(regX);
  477. }
  478.  
  479. //////////////////////////////////////////////
  480. //
  481. //    _INY    Increment Y by one
  482. //
  483. //////////////////////////////////////////////
  484. void _INY(void)
  485. {
  486.     regY++;
  487.     SETNSTATUS(regY);
  488.     SETZSTATUS(regY);
  489. }
  490.  
  491. //////////////////////////////////////////////
  492. //
  493. //    _JMP    Jump to new location
  494. //
  495. //////////////////////////////////////////////
  496. void _JMP(UInt16 address)
  497. {
  498.     pc = address;
  499. }
  500.  
  501. //////////////////////////////////////////////
  502. //
  503. //    _JSR    Jump to SubRoutine
  504. //
  505. //////////////////////////////////////////////
  506. void _JSR(UInt16 address)
  507. {
  508.     PushWord(pc -1);
  509.     pc = address;
  510. }
  511.  
  512. //////////////////////////////////////////////
  513. //
  514. //    _LDA    Load accumulator
  515. //
  516. //////////////////////////////////////////////
  517. void _LDA(UInt8 opByte)
  518. {
  519.     regA = opByte;
  520.  
  521.     SETNSTATUS(regA);
  522.     SETZSTATUS(regA);
  523. }
  524.  
  525. //////////////////////////////////////////////
  526. //
  527. //    _LDX    Load X
  528. //
  529. //////////////////////////////////////////////
  530. void _LDX(UInt8 opByte)
  531. {
  532.     regX = opByte;
  533.  
  534.     SETNSTATUS(regX);
  535.     SETZSTATUS(regX);
  536. }
  537.  
  538. //////////////////////////////////////////////
  539. //
  540. //    _LDY    Load Y
  541. //
  542. //////////////////////////////////////////////
  543. void _LDY(UInt8 opByte)
  544. {
  545.     regY = opByte;
  546.  
  547.     SETNSTATUS(regY);
  548.     SETZSTATUS(regY);
  549. }
  550.  
  551. //////////////////////////////////////////////
  552. //
  553. //    _LSR        Logical shift right
  554. //
  555. //////////////////////////////////////////////
  556. void _LSR(UInt8* addr)
  557. {
  558.     UInt8 theBye = ((*addr) >> 1);
  559.     if (*addr & 0x01)
  560.         SETSTATUSBIT(CBit);
  561.     else
  562.         CLEARSTATUSBIT(CBit);
  563.  
  564.     *addr = theBye;
  565.     SETNSTATUS(theBye);
  566.     SETZSTATUS(theBye);
  567. }
  568.  
  569. //////////////////////////////////////////////
  570. //
  571. //    _NOP        No operation
  572. //
  573. //////////////////////////////////////////////
  574. void _NOP(void)
  575. {
  576.     return;
  577. }
  578.  
  579. //////////////////////////////////////////////
  580. //
  581. //    _ORA    Or with Accumulator
  582. //
  583. //////////////////////////////////////////////
  584. void _ORA(UInt8 opByte)
  585. {
  586.     regA |= opByte;
  587.     SETNSTATUS(regA);
  588.     SETZSTATUS(regA);
  589. }
  590.  
  591. //////////////////////////////////////////////
  592. //
  593. //    _PHA    Push A on stack
  594. //
  595. //////////////////////////////////////////////
  596. void _PHA(void)
  597. {
  598.     PushByte(regA);
  599. }
  600.  
  601. //////////////////////////////////////////////
  602. //
  603. //    _PHP    Push P on stack
  604. //
  605. //////////////////////////////////////////////
  606. void _PHP(void)
  607. {
  608.     PushByte(regP);
  609. }
  610.  
  611. //////////////////////////////////////////////
  612. //
  613. //    _PLA    Pop A from stack
  614. //
  615. //////////////////////////////////////////////
  616. void _PLA(void)
  617. {
  618.     regA = PopByte();
  619.     SETNSTATUS(regA);
  620.     SETZSTATUS(regA);
  621. }
  622.  
  623. //////////////////////////////////////////////
  624. //
  625. //    _PLP    Pop P from stack
  626. //
  627. //////////////////////////////////////////////
  628. void _PLP(void)
  629. {
  630.     regP = PopByte();
  631. }
  632.  
  633. //////////////////////////////////////////////
  634. //
  635. //    _ROL        Rotate left through carry
  636. //
  637. //////////////////////////////////////////////
  638. void _ROL(UInt8* addr)
  639. {
  640.     UInt8 theBye = ((*addr) << 1);
  641.     
  642.     if (GETSTATUS(CBit))
  643.         theBye |= 0x01;
  644.  
  645.     if (*addr & 0x80)
  646.         SETSTATUSBIT(CBit);
  647.     else
  648.         CLEARSTATUSBIT(CBit);
  649.  
  650.     *addr = theBye;
  651.     SETNSTATUS(theBye);
  652.     SETZSTATUS(theBye);
  653. }
  654.  
  655. //////////////////////////////////////////////
  656. //
  657. //    _ROR        Rotate right through carry
  658. //
  659. //////////////////////////////////////////////
  660. void _ROR(UInt8* addr)
  661. {
  662.     UInt8 theBye = ((*addr) >> 1);
  663.     
  664.     if (GETSTATUS(CBit))
  665.         theBye |= 0x80;
  666.  
  667.     if (*addr & 0x01)
  668.         SETSTATUSBIT(CBit);
  669.     else
  670.         CLEARSTATUSBIT(CBit);
  671.  
  672.     *addr = theBye;
  673.     SETNSTATUS(theBye);
  674.     SETZSTATUS(theBye);
  675. }
  676.  
  677. //////////////////////////////////////////////
  678. //
  679. //    RTI        Return From Interupt
  680. //
  681. //////////////////////////////////////////////
  682. void _RTI(void)
  683. {
  684.     regP = PopByte();
  685.     pc = PopWord();
  686. }
  687.  
  688. //////////////////////////////////////////////
  689. //
  690. //    RTS        Return Subroutine
  691. //
  692. //////////////////////////////////////////////
  693. void _RTS(void)
  694. {
  695.     UInt8 oldsp = sp;
  696.     UInt16 addr = PopWord();
  697.     if (oldsp < sp) {
  698.         gDone = true;
  699.         return;
  700.     }
  701.     pc = addr;
  702.     pc++;
  703. }
  704.  
  705. //////////////////////////////////////////////
  706. //
  707. //    SBC        Subtract with Carry to A
  708. //
  709. //////////////////////////////////////////////
  710. void _SBC(UInt8 opByte)
  711. {
  712.     SInt16 a_a,  a_opByte, result, tempA, tempopByte;
  713.  
  714.     if (GETSTATUS(DBit)) {
  715.         a_a = (((regA & 0xF0) >> 4) * 10) + (regA & 0x0F);
  716.         a_opByte = (((opByte & 0xF0) >> 4) * 10) + (opByte & 0x0F);
  717.         result = a_a - a_opByte;
  718.  
  719.         if (result <0) {
  720.             SETSTATUSBIT(CBit);
  721.             result = 100 - result;
  722.         }
  723.         else {
  724.             CLEARSTATUSBIT(CBit);
  725.         }
  726.         regA = ((result % 10)  + ((result / 10) << 4));
  727.     }
  728.     else {
  729.         tempA = UInt8ToSInt16(regA);
  730.         tempopByte = UInt8ToSInt16(opByte);
  731.  
  732.         result = (tempA + GETSTATUS(CBit) + (255 - tempopByte));
  733.  
  734.         tempA = UInt8ToSInt16(regA);
  735.         tempopByte = UInt8ToSInt16(opByte);
  736.  
  737.         if (((tempA<128) && (tempopByte<128) && ((result & 0xFF)>127)) ||
  738.             ((tempA>127) && (tempopByte>127) && ((result & 0xFF)<128))) {
  739.             SETSTATUSBIT(VBit);
  740.         }
  741.         else {
  742.             CLEARSTATUSBIT(VBit);
  743.         }
  744.  
  745.         if (result > 255) {
  746.             SETSTATUSBIT(CBit);
  747.         }
  748.         else {
  749.             CLEARSTATUSBIT(CBit);
  750.         }
  751.         regA = (result & 0xFF);
  752.     }
  753.     SETNSTATUS(regA);
  754.     SETZSTATUS(regA);
  755. }
  756.  
  757. //////////////////////////////////////////////
  758. //
  759. //    _SEC        Set Carry
  760. //
  761. //////////////////////////////////////////////
  762. void _SEC(void)
  763. {
  764.     regP |= CBit;
  765. }
  766.  
  767. //////////////////////////////////////////////
  768. //
  769. //    _SED        Set Decimal Mode
  770. //
  771. //////////////////////////////////////////////
  772. void _SED(void)
  773. {
  774.     regP |= DBit;
  775. }
  776.  
  777. //////////////////////////////////////////////
  778. //
  779. //    _SEI        Set IRQ Disable
  780. //
  781. //////////////////////////////////////////////
  782. void _SEI(void)
  783. {
  784.     regP |= IBit;
  785. }
  786.  
  787. //////////////////////////////////////////////
  788. //
  789. //    _STA    Store A
  790. //
  791. //////////////////////////////////////////////
  792. void _STA(UInt8* addr)
  793. {
  794.      *addr = regA;
  795. }
  796.  
  797. //////////////////////////////////////////////
  798. //
  799. //    _STX    Store X
  800. //
  801. //////////////////////////////////////////////
  802. void _STX(UInt8* addr)
  803. {
  804.      *addr = regX;
  805. }
  806.  
  807. //////////////////////////////////////////////
  808. //
  809. //    _STY    Store Y
  810. //
  811. //////////////////////////////////////////////
  812. void _STY(UInt8* addr)
  813. {
  814.      *addr = regY;
  815. }
  816.  
  817. //////////////////////////////////////////////
  818. //
  819. //    _TAX    Transfer A to X
  820. //
  821. //////////////////////////////////////////////
  822. void _TAX(void)
  823. {
  824.      regX = regA;
  825.      SETNSTATUS(regX);
  826.      SETZSTATUS(regX);
  827. }
  828.  
  829. //////////////////////////////////////////////
  830. //
  831. //    _TAY    Transfer A to Y
  832. //
  833. //////////////////////////////////////////////
  834. void _TAY(void)
  835. {
  836.      regY = regA;
  837.      SETNSTATUS(regA);
  838.      SETZSTATUS(regA);
  839. }
  840.  
  841. //////////////////////////////////////////////
  842. //
  843. //    _TSX    Transfer Stack to X
  844. //
  845. //////////////////////////////////////////////
  846. void _TSX(void)
  847. {
  848.      regX = sp;
  849.      SETNSTATUS(regX);
  850.      SETZSTATUS(regX);
  851. }
  852.  
  853. //////////////////////////////////////////////
  854. //
  855. //    _TXA    Transfer X to A
  856. //
  857. //////////////////////////////////////////////
  858. void _TXA(void)
  859. {
  860.      regA = regX;
  861.      SETNSTATUS(regA);
  862.      SETZSTATUS(regA);
  863. }
  864.  
  865. //////////////////////////////////////////////
  866. //
  867. //    _TXS    Transfer X to Stack
  868. //
  869. //////////////////////////////////////////////
  870. void _TXS(void)
  871. {
  872.      sp = regX;
  873.      SETNSTATUS(sp);
  874.      SETZSTATUS(sp);
  875. }
  876.  
  877. //////////////////////////////////////////////
  878. //
  879. //    _TYA    Transfer Y to A
  880. //
  881. //////////////////////////////////////////////
  882. void _TYA(void)
  883. {
  884.      regA = regY;
  885.      SETNSTATUS(regA);
  886.      SETZSTATUS(regA);
  887. }
  888.  
  889.